<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>

<script>
  import { mapState,mapMutations, mapActions} from 'vuex'
  import Store from '@/store'
  import Msg from '@/utils/msg'
  import Utils from '@/utils/common'
  import Validator from '@/utils/validate'
  import Auth from '@/auth'
  import API from '@/api'
  import Http from '@/http'

  export default {
    name: 'app',
    data() {
      return {
        prevRoutes: [],
        company:Store.getters.user.company,
      }
    },
    watch: { },
    computed: {},
    methods: {

    },
    components: {
    },
    created() {
      //初始化基础数据
      Store.dispatch('initBasedata')
      //根据cookie的token获取用户信息
      let auth_token = Store.getters.token
      if(!Validator.isEmpty(auth_token)){
        Auth.getUserByToken(auth_token).then((json)=>{
          if (json.code == 0) {
             let user = json.data
             Store.commit("SET_USER",user)
			 Store.commit("SET_COMPANY",user.company)
             Http.getModel(API.get_company_tips, {}, false).then((json) => {
               if (json.code == 0) {
                 Store.commit("SET_MSGTIPS",json.data)
               }
             })
          }
        })
      }
    },
    mounted(){
      let that = this

    }
  };
</script>
